package com.ryan.mdp.connection;

import javax.jms.ConnectionFactory;

import org.springframework.jms.connection.CachingConnectionFactory;

/**
 * 非atomikos JTA事务支持连接工厂.<br>
 * 如果要在oc4j、weblogic等提供JTA实现的容器中使用JTA事务，请直接使用setTargetConnectionFactory(
 * ConnectionFactory connectionFactory)注入来至于ejb容器JNDI的ConnectionFactory对象.
 * 
 * @author botao.liao
 * 
 */
public class MdpConnectionFactory extends CachingConnectionFactory {

    // jms连接配置信息文件路径
    private String properties;
    // jms连接配置信息中的key前缀
    private String prefix;

    // 是否需要分布式事务

    @Override
    public void afterPropertiesSet() {
        // 外部注入ConnectionFactory
        if (getTargetConnectionFactory() != null) {
            return;
        }
        ConnectionFactory connectionFactory = JndiConnectionFactoryUtil.getConnectionFactory(prefix, properties);
        setTargetConnectionFactory(connectionFactory);
    }

    public String getProperties() {
        return properties;
    }

    public void setProperties(String properties) {
        this.properties = properties;
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }
}
